{% extends 'TopxiaWebBundle::bootstrap-modal-layout.html.twig' %}

{% set modalSize = 'large' %}

{% set member = member|default(null) %}

{% block title %}{% if member %}编辑{% else %}创建{% endif %}会员{% endblock %}
{% block body %}

<form id="member-modal-form" class="form-horizontal" method="post"
  {% if member %}
     action="{{ url('admin_vip_edit', {userId:member.userId}) }}"
  {% else %}
     action="{{ url('admin_vip_create') }}"
  {% endif %}
>
<div class="row form-group">
    <div class="col-md-2 control-label">
      <label for="nickname">用户名</label>
    </div>
    <div class="col-md-7 controls">
    {% if member %}
      <div class = "control-text">{{user.nickname|default('')}}</div>
    {% else %}
      <input type="text" id="nickname" name="nickname" data-url="{{path('admin_vip_create_nickname_check')}}" class="form-control" >
    {% endif %}
    </div>
  </div>
  <div class="row form-group">
    <div class="col-md-2 control-label">
      <label for="levels">会员等级</label>
    </div>
    <div class="col-md-7 controls">
     <select class="form-control" name="levelId">
       {% if member %}
         {{ select_options(levels_enabled, member.levelId) }}
        {% else %}
         {{ select_options(levels_enabled, member.levelId|default(''), '--按会员等级--') }}
       {% endif %}
     </select>
    </div>
  </div>

  <div class="row form-group">
     <div class="col-md-2 control-label">
      <label for="levels">付费方式</label>
    </div>
     <div class="col-md-7 controls radios">
        {{ radios('boughtUnit', {month:'按月', year:'按年'}, member.boughtUnit|default('month')) }}
      </div>
  </div> 

    <div class="form-group">
         <label  class="col-md-2 control-label" for="boughtDuration">开通时长</label>
         {% if member %}
              <div class="col-md-7 controls" style="z-index:2000;">
                <input type="text" id="deadline" name="deadline"  class="form-control" value="{{member.deadline | date('Y-m-d')}}">
            </div>
         {% else %}
            <div class="col-md-8 controls">
              <input type="text" id="boughtDuration" name="boughtDuration" required="required" class="form-control width-input width-input-large"   > 月(年)
            </div>
        {% endif %}
      </div>


    <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">           

</form>
{% endblock %}

{% block footer %}
  <button type="submit" class="btn btn-primary pull-right" data-toggle="form-submit" data-target="#member-modal-form">保存</button>
  <button type="button" class="btn btn-link pull-right" data-dismiss="modal">取消</button>
  {% if member %}
    <script>app.load('vipbundle/controller/vipadmin/edit-modal')</script>
  {% else %}
    <script>app.load('vipbundle/controller/vipadmin/create-modal')</script>
  {% endif %}
{% endblock %}